home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / libs / unixlib.lha / unix / src / pseudo_c.c < prev    next >
C/C++ Source or Header  |  1996-11-12  |  563b  |  28 lines

  1. #include "amiga.h"
  2. #include "files.h"
  3. #include <fcntl.h>
  4.  
  5. int _pseudo_close(int fd)
  6. {
  7.     struct fileinfo *fi;
  8.  
  9.     __chkabort();
  10.     if (fi = _find_fd(fd)) {
  11.     int err = 0;
  12.     if (fi->count == 1)
  13.         err = fi->close(fi->userinfo, TRUE);
  14. /*
  15.  * On return err is 0 if no error occurred, and negative otherwise.
  16.  * But if fd was the descriptor of a socket we get a positive value
  17.  * and thus not free the slot: the callback function called by AmiTCP
  18.  * will do that for us.
  19.  */
  20.     if (err <= 0)
  21.         _free_fd(fd);
  22.     else
  23.         err = 0;
  24.     return err;
  25.     }
  26.     return -1;
  27. }
  28.